package com.unitd.base.module.test.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.unitd.base.frame.plugin.db.datasource.annotion.DataSource;
import com.unitd.base.frame.plugin.db.enums.DBTypeEnum;
import com.unitd.base.module.test.mybatis.mapper.DataSourceMapper;
import com.unitd.base.module.test.po.DataSourcePO;
import com.unitd.base.module.test.service.DataSourceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 数据源信息表信息业务逻辑处理接口实现类
 *
 * @author Hudan
 * @version 1.0
 * @filename DataSourceServiceImpl.java
 * @copyright www.unitd.com
 * @date 2020-06-23
 */
@Service
@Slf4j
public class DataSourceServiceImpl extends ServiceImpl<DataSourceMapper, DataSourcePO> implements DataSourceService {

    /**
     * 根据数据源类型查找有效的数据源信息
     *
     * @param dbType 数据源类型
     * @return 数据源信息
     */
    @Override
    @DataSource(name = "shoe")
    public List<DataSourcePO> selectByDbType(DBTypeEnum dbType) {
        return baseMapper.selectByDbType(dbType.getCode());
    }
}